home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-04-24 | 2.4 KB | 99 lines | [TEXT/MPS ] |
- program DragExample1;
- {$D+} {put in debug names}
- {$R+} {range checking on}
- {$OV+} {overflow checking on}
- {$N+} {pass routine names to linker, so they're not anonymous}
- USES {$LOAD pinterfaces.dump}
- MemTypes,QuickDraw,OsIntf,PasLibIntf,ToolIntf,
- PackIntf,IntEnv,CursorCtl,
- {$LOAD}
- {$U UDrag.p} DragManager;
-
- var
- myPic : PicHandle;
- myRect : Rect;
- wPort: GrafPtr;
- whichPict,
- x,y,xinc,yinc : integer;
- xyPt, lastXYPt : point;
- myEventRecord : EventRecord;
- lastCount : longint;
-
- myDragStuff : DragHandle;
-
- procedure DragItAround;
- const
- CapsLockBit = 10;
- begin
- SetPt( lastXYPt, -1, -1 );
- repeat
- GetMouse(xyPt);
- {if the movement is far enough, the next line of code (commented out)
- can be used to make the image persist long enough that it doesn't appear
- ghostly. On the other hand, if the movement is very small, the image
- generally looks nice and solid and does not benefit from delays.}
- {if TickCount >= lastCount + 2 then}
- if not EqualPt( xyPt, lastXYPt) then
- begin
- {if CapsLockKey, don't show the shadow, else show it}
- if EventAvail(0, myEventRecord) then {twiddle thumbs};
- if BTST(myEventRecord.modifiers, CapsLockBit)
- then with shadowStuff do
- begin dx := 0; dy := 0; visible := false; end
- else with shadowStuff do
- begin
- dx := xyPt.h div 8 - 32;
- dy := xyPt.v div 8 - 20;
- visible := true;
- end;
-
- DragItTo( myDragStuff, xyPt, true );
-
- lastXYPt := xyPt;
- lastCount := TickCount;
- end;
- {allow for FKEY access and give DAs and such time}
- if GetNextEvent( keyDownMask, myEventRecord ) then {do nothing};
- SystemTask;
- until button;
- repeat until not button;
- end; {dragitaround}
-
- begin{main}
- InitGraf(@thePort);
-
- {standalones need to init windows, but tools shouldn't}
- if IEStandalone then InitWindows;
-
- GetWMgrPort( wPort );
- SetPort( wPort );
- ClipRect( screenBits.bounds );
- InitCursor;
- HideCursor;
-
- if not InitDrag( nil ) then exit( DragExample1 );
-
- for whichPict := 1 to CountResources('PICT') do
- begin
- myPic := PicHandle(GetIndResource('PICT', whichPict));
- if myPic = nil then
- begin SysBeep(1); exit(DragExample1); end;
- {change up the default shadow stuff}
- with shadowStuff do
- begin
- thePattern := gray;
- copyMode := SrcOr;
- end;
-
- if not NewDraggable( myPic, nil, nil, myDragStuff )
- then exit(DragExample1);
- DragItAround;
- DisposeDraggable( myDragStuff );
- ReleaseResource( Handle( myPic ));
- end;
-
- CloseDrag( true );
- FlushEvents( everyEvent, 0 );
-
- end.
-